<?php

class Fpage {
	var $db;
 	var $smarty;	
	public function __construct($db, $smarty,$page='',$cat='',$product='') {
		$this->db = $db;
		$this->smarty = $smarty;
		$this->page = $page;
		$this->cat = $cat;
		$this->product = $product;
	}
	
	public function main() {
		$thispage = '';
		$menuID = '';
		if(isset($this->cat) && $this->cat != '')
			$thispage = $this->cat;
		else		
			$thispage = $this->page;
		$page = FIN_categoryBean::get_page_by_Url($this->db,$thispage);
		$page->cat_description=FDocument::ChangePath($page->cat_description);
		$page->cat_description=FDocument::ChangeLink($page->cat_description);
		if(isset($page->cat_parent) && $page->cat_parent != 0)
			$menuID = $page->cat_parent;
		else		
			$menuID = $page->cat_ID;
		$childs = FIN_categoryBean::getCategoryByParent($this->db,$menuID);
		if($childs!=''){
			foreach($childs as $item){
					$item->paralink = FOLDER_HOST.$this->page.'/'.$item->url;		
			}
		}
		$this->smarty->assign("CHILDS", $childs);
		$this->smarty->assign("PATHBG", UPLOAD_FILES);
		$this->smarty->assign("PATHTITLE", $page->cat_name);
		$this->smarty->assign("PAGECONTENT", $page);
		$this->smarty->display("page.tpl");	
	}
	
	
	
}
?>
